import request from '@/utils/request'
// 导入store
import store from '@/store'

// 封装一个获取用户资料的接口
export const userInfo = () => {

    return request({
        url: '/v1_0/user/profile', //编辑用户个人资料
        headers: {
            Authorization: 'Bearer ' + store.state.tokenObj.token
        }
    })
}

// 修改用户个人信息，传的参数都是小写，method不要加s
export const editProfile = (data) => {
    //data是axios请求到的数据
    return request({
        url: '/v1_0/user/profile',
        method: 'patch',
        data
    })
}



// 修改用户头像
export const editAvatar = (data) => {

    return request({
        url: '/v1_0/user/photo', //编辑用户照片资料
        method: 'patch',
        data
    })
}


// 关注
export const followUser = (data) => {

    return request({
        url: '/v1_0/user/followings',//关注用户
        method: 'post',
        data
    })
}

// 取关
export const unfollowUser = (id) => {

    return request({
        url: '/v1_0/user/followings/' + id,
        method: 'delete',
    })
}